/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * CDialogoBdCenarioEdicao.java
 *
 * Created on 20/05/2010, 08:57:25
 */
package rpt.bd.cenario;

import java.awt.event.ActionEvent;
import java.util.HashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.table.DefaultTableModel;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.view.JasperViewer;
import rpt.lib.relatorio.CRelatorioBasicoCenario;

/**
 *
 * @author Roberto
 */
/**************************************************************************/
/***                                                                    ***/
/**************************************************************************/
public class CDialogoBdCenarioEdicao extends CDialogoBdCenario {

    /**************************************************************************/
    /***                                                                    ***/
    /**************************************************************************/
    CCenarioBdEdicao fCenarioBdEdicao;

    /**************************************************************************/
    /***                                                                    ***/
    /**************************************************************************/
    public CDialogoBdCenarioEdicao(final CCenarioBdEdicao aCenarioBdEdicao) {
        super(aCenarioBdEdicao);
        initComponents();
        fCenarioBdEdicao = aCenarioBdEdicao;
        HabilitarBotoes(true, true, true, false, false, true);

        prepararBotao(swBtnGeral1, fCenarioBdEdicao.getPainelBd().getBotaoGeral1());
        prepararBotao(swBtnGeral2, fCenarioBdEdicao.getPainelBd().getBotaoGeral2());
        prepararBotao(swBtnGeral3, fCenarioBdEdicao.getPainelBd().getBotaoGeral3());
        /*
        swBtnGeral1.setVisible(fCenarioBdEdicao.fPainelBd.getBotaoGeral1() != null);
        swBtnGeral2.setVisible(fCenarioBdEdicao.fPainelBd.getBotaoGeral2() != null);
        swBtnGeral3.setVisible(fCenarioBdEdicao.fPainelBd.getBotaoGeral3() != null);
         */
    }

    /**************************************************************************/
    /***                                                                    ***/
    /**************************************************************************/
    @Override
    public JPanel PainelCentral() {
        return swPnlCentral;
    }

    /**************************************************************************/
    /***                                                                    ***/
    /**************************************************************************/
    private void HabilitarBotoes(
            final boolean aAtualizar,
            final boolean aIncluir,
            final boolean aAlterar,
            final boolean aSalvar,
            final boolean aCancelar,
            final boolean aExcluir) {
        swBtnAtualizar.setEnabled(aExcluir);
        swBtnIncluir.setEnabled(aIncluir);
        final int vNumLinhas = fPertinenciaBd.getConjuntoDadosBd().getConjuntoDados().size();
        swBtbAlterar.setEnabled(((aAlterar) && (vNumLinhas > 0)));
        swBtnSalvar.setEnabled(aSalvar);
        swBtnCancelar.setEnabled(aCancelar);
        swBtnExcluir.setEnabled(aExcluir);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    /**************************************************************************/
    /***                                                                    ***/
    /**************************************************************************/
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        swPnlTopo = new javax.swing.JPanel();
        swPnlCentral = new javax.swing.JPanel();
        swPnlFundo = new javax.swing.JPanel();
        swBtnAtualizar = new javax.swing.JButton();
        swBtnIncluir = new javax.swing.JButton();
        swBtbAlterar = new javax.swing.JButton();
        swBtnSalvar = new javax.swing.JButton();
        swBtnCancelar = new javax.swing.JButton();
        swBtnExcluir = new javax.swing.JButton();
        swBtnRelatorio = new javax.swing.JButton();
        swBtnGeral1 = new javax.swing.JButton();
        swBtnGeral2 = new javax.swing.JButton();
        swBtnGeral3 = new javax.swing.JButton();

        setLayout(new java.awt.BorderLayout());

        swPnlTopo.setBackground(new java.awt.Color(230, 230, 230));

        javax.swing.GroupLayout swPnlTopoLayout = new javax.swing.GroupLayout(swPnlTopo);
        swPnlTopo.setLayout(swPnlTopoLayout);
        swPnlTopoLayout.setHorizontalGroup(
            swPnlTopoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 988, Short.MAX_VALUE)
        );
        swPnlTopoLayout.setVerticalGroup(
            swPnlTopoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );

        add(swPnlTopo, java.awt.BorderLayout.NORTH);

        swPnlCentral.setLayout(new java.awt.BorderLayout());
        add(swPnlCentral, java.awt.BorderLayout.CENTER);

        swPnlFundo.setBackground(new java.awt.Color(230, 230, 230));

        swBtnAtualizar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/rpt/imagem/icone/basico/Down.png"))); // NOI18N
        swBtnAtualizar.setToolTipText("Atualizar");
        swBtnAtualizar.setAutoscrolls(true);
        swBtnAtualizar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                swBtnAtualizarActionPerformed(evt);
            }
        });

        swBtnIncluir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/rpt/imagem/icone/basico/Plus.png"))); // NOI18N
        swBtnIncluir.setToolTipText("Incluir");
        swBtnIncluir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                swBtnIncluirActionPerformed(evt);
            }
        });

        swBtbAlterar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/rpt/imagem/icone/basico/Pencil.png"))); // NOI18N
        swBtbAlterar.setToolTipText("Alterar");
        swBtbAlterar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                swBtbAlterarActionPerformed(evt);
            }
        });

        swBtnSalvar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/rpt/imagem/icone/basico/Save.png"))); // NOI18N
        swBtnSalvar.setToolTipText("Salvar");
        swBtnSalvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                swBtnSalvarActionPerformed(evt);
            }
        });

        swBtnCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/rpt/imagem/icone/basico/Delete.png"))); // NOI18N
        swBtnCancelar.setToolTipText("Cancelar");
        swBtnCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                swBtnCancelarActionPerformed(evt);
            }
        });

        swBtnExcluir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/rpt/imagem/icone/basico/Trash.png"))); // NOI18N
        swBtnExcluir.setToolTipText("Excluir");
        swBtnExcluir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                swBtnExcluirActionPerformed(evt);
            }
        });

        swBtnRelatorio.setIcon(new javax.swing.ImageIcon(getClass().getResource("/rpt/imagem/icone/basico/Print.png"))); // NOI18N
        swBtnRelatorio.setToolTipText("Relatório");
        swBtnRelatorio.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                swBtnRelatorioActionPerformed(evt);
            }
        });

        swBtnGeral1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/rpt/imagem/icone/basico/Warning.png"))); // NOI18N
        swBtnGeral1.setToolTipText("Geral 1");
        swBtnGeral1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                swBtnGeral1ActionPerformed(evt);
            }
        });

        swBtnGeral2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/rpt/imagem/icone/basico/Warning.png"))); // NOI18N
        swBtnGeral2.setToolTipText("Geral 2");
        swBtnGeral2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                swBtnGeral2ActionPerformed(evt);
            }
        });

        swBtnGeral3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/rpt/imagem/icone/basico/Warning.png"))); // NOI18N
        swBtnGeral3.setToolTipText("Geral 3");
        swBtnGeral3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                swBtnGeral3ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout swPnlFundoLayout = new javax.swing.GroupLayout(swPnlFundo);
        swPnlFundo.setLayout(swPnlFundoLayout);
        swPnlFundoLayout.setHorizontalGroup(
            swPnlFundoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(swPnlFundoLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(swBtnAtualizar, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(swBtnIncluir, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(swBtbAlterar, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(swBtnSalvar, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(swBtnCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(swBtnExcluir, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(swBtnRelatorio, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(swBtnGeral1, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(swBtnGeral2, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(swBtnGeral3, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(174, Short.MAX_VALUE))
        );
        swPnlFundoLayout.setVerticalGroup(
            swPnlFundoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(swPnlFundoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(swPnlFundoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(swBtnGeral3, javax.swing.GroupLayout.DEFAULT_SIZE, 75, Short.MAX_VALUE)
                    .addComponent(swBtnGeral2, javax.swing.GroupLayout.DEFAULT_SIZE, 75, Short.MAX_VALUE)
                    .addComponent(swBtnGeral1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 75, Short.MAX_VALUE)
                    .addComponent(swBtnRelatorio, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 75, Short.MAX_VALUE)
                    .addComponent(swBtnExcluir, javax.swing.GroupLayout.DEFAULT_SIZE, 75, Short.MAX_VALUE)
                    .addComponent(swBtnCancelar, javax.swing.GroupLayout.DEFAULT_SIZE, 75, Short.MAX_VALUE)
                    .addComponent(swBtnSalvar, javax.swing.GroupLayout.DEFAULT_SIZE, 75, Short.MAX_VALUE)
                    .addComponent(swBtbAlterar, javax.swing.GroupLayout.DEFAULT_SIZE, 75, Short.MAX_VALUE)
                    .addComponent(swBtnIncluir, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 75, Short.MAX_VALUE)
                    .addComponent(swBtnAtualizar, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        add(swPnlFundo, java.awt.BorderLayout.SOUTH);
    }// </editor-fold>//GEN-END:initComponents

    /**************************************************************************/
    /***                                                                    ***/
    /**************************************************************************/
    private void setCores() {
        CRegistroBd r = null;
        CGradeBdCenario g = fCenarioBdEdicao.getGrade();
        if (g != null) {
            r = g.getRegistroBdAtual();
            if (r != null) {
                r.setCoresCamposRegistroBd();
            }
        }
    }

    /**************************************************************************/
    /***                                                                    ***/
    /**************************************************************************/
    private void acaoIncluir(final ActionEvent evt) {
        fPertinenciaBd.incluir();
        if (fDialogoCentral instanceof CDialogoGradeBdFormBd) {
            ((CDialogoGradeBdFormBd) fDialogoCentral).incluir();
        }
        HabilitarBotoes(false, false, false, true, true, false);
        fPertinenciaBd.setLiberarEdicao(true, true);
        setCores();
    }

    /**************************************************************************/
    /***                                                                    ***/
    /**************************************************************************/
    private void swBtnIncluirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_swBtnIncluirActionPerformed
        acaoIncluir(evt);
    }//GEN-LAST:event_swBtnIncluirActionPerformed

    /**************************************************************************/
    /***                                                                    ***/
    /**************************************************************************/
    private void acaoAlterar(final ActionEvent evt) {
        fPertinenciaBd.alterar();
        if (fDialogoCentral instanceof CDialogoGradeBdFormBd) {
            ((CDialogoGradeBdFormBd) fDialogoCentral).alterar();
        }
        HabilitarBotoes(false, false, false, true, true, false);
        fPertinenciaBd.setLiberarEdicao(true, false);
        setCores();
    }

    /**************************************************************************/
    /***                                                                    ***/
    /**************************************************************************/
    private void swBtbAlterarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_swBtbAlterarActionPerformed
        acaoAlterar(evt);
}//GEN-LAST:event_swBtbAlterarActionPerformed

    /**************************************************************************/
    /***                                                                    ***/
    /**************************************************************************/
    private void acaoSalvar(final ActionEvent evt) {
        final CGradeBdCenario g = fCenarioBdEdicao.getGrade();
        if (g != null) {
            final CRegistroBd r = g.getRegistroBdAtual();
            if (r != null) {
                final CResultadoGravacao vResGravacao = fPertinenciaBd.gravar(r);
                final int vRes = vResGravacao.getResultado();
                if (vRes > -1) {
                    HabilitarBotoes(true, true, true, false, false, true);
                    fPertinenciaBd.setLiberarEdicao(false, false);
                    if (fDialogoCentral instanceof CDialogoGradeBdFormBd) {
                        ((CDialogoGradeBdFormBd) fDialogoCentral).salvar();
                    }
                    fPertinenciaBd.salvar();
                    if (vRes > 0) {
                        r.setValorCampoRegistroBdChavePrimaria(vRes);
                        //r.buscarCamposTabela
                        g.atualizarCampoRegistroBd(r, null, r.getCampoRegistroBdChavePrimaria());
                    }
                    r.setValoresOriginaisCamposRegistroBd(false);
                    fCenarioBdEdicao.getGrade().requestFocus();
                }
            }
        }
    }

    /**************************************************************************/
    /***                                                                    ***/
    /**************************************************************************/
    private void swBtnSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_swBtnSalvarActionPerformed
        acaoSalvar(evt);
    }//GEN-LAST:event_swBtnSalvarActionPerformed

    private void swBtnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_swBtnCancelarActionPerformed
        acaoCancelar(evt);
}//GEN-LAST:event_swBtnCancelarActionPerformed

    /**************************************************************************/
    /***                                                                    ***/
    /**************************************************************************/
    private void removerRegistroAtual(final EStatusOperacao aStatusOperacao) {
        CRegistroBd r = null;
        final CGradeBdCenario g = fCenarioBdEdicao.getGrade();
        if (g != null) {
            r = g.getRegistroBdAtual();
            if (r != null) {
                r.setValoresOriginaisCamposRegistroBd(true);
                if ((aStatusOperacao == EStatusOperacao.inclusao) || (aStatusOperacao == EStatusOperacao.exclusao)) {
                    CConjuntoDadosBd cd = fPertinenciaBd.getConjuntoDadosBd();
                    cd.removerRegistroBd(r);
                    g.setRegistroBdAtual(g.getRegistroBdAnterior());
                    g.setRegistroBdLinhaAtual(g.getRegistroBdLinhaAnterior());
                } else {
                    r.setValoresOriginaisCamposRegistroBd(true);
                }
            }
            final DefaultTableModel m = (DefaultTableModel) g.getModel();
            m.fireTableDataChanged();
            int vLinhaSelecao = -1;
            vLinhaSelecao = g.getRegistroBdLinhaAtual();
            if (vLinhaSelecao >= 0) {
                g.setRowSelectionInterval(vLinhaSelecao, vLinhaSelecao);
            }
        }
    }

    /**************************************************************************/
    /***                                                                    ***/
    /**************************************************************************/
    private void acaoCancelar(final ActionEvent evt) {
        final EStatusOperacao vStatusOperacao = fPertinenciaBd.getStatusOperacao();
        removerRegistroAtual(vStatusOperacao);
        HabilitarBotoes(true, true, true, false, false, true);
        fPertinenciaBd.setLiberarEdicao(false, false);
        if (fDialogoCentral instanceof CDialogoGradeBdFormBd) {
            ((CDialogoGradeBdFormBd) fDialogoCentral).cancelar();
        }
        fPertinenciaBd.cancelar();
        setCores();
        fCenarioBdEdicao.getGrade().requestFocus();
    }

    /**************************************************************************/
    /***                                                                    ***/
    /**************************************************************************/
    private void acaoExcluir(final ActionEvent evt) {
        HabilitarBotoes(false, false, false, false, false, false);
        fPertinenciaBd.excluir();
        if (fDialogoCentral instanceof CDialogoGradeBdFormBd) {
            ((CDialogoGradeBdFormBd) fDialogoCentral).excluir();
        }
        final CGradeBdCenario g = fCenarioBdEdicao.getGrade();
        CRegistroBd r = (CRegistroBd) fCenarioBdEdicao.getRegistroBdAtual();
        if (r != null) {
            String s = r.getCampoRegistroBdChavePrimaria().getValorCampoBdStr();
            Object[] options = {"Sim", "Não"};
            int n = JOptionPane.showOptionDialog(this,
                    "Confirmar excluir \no registro [" + s + "]?",
                    "Exclusão de Registro",
                    JOptionPane.YES_NO_OPTION,
                    JOptionPane.QUESTION_MESSAGE,
                    null, options, options[1]);
            if (n == 0) {
                final CResultadoGravacao vResGravacao = fPertinenciaBd.gravar(r);
                final int vRes = vResGravacao.getResultado();
                if (vRes > -1) {
                    if (fDialogoCentral instanceof CDialogoGradeBdFormBd) {
                        ((CDialogoGradeBdFormBd) fDialogoCentral).salvar();
                    }
                    fPertinenciaBd.salvar();
                    removerRegistroAtual(EStatusOperacao.exclusao);
                    r = fCenarioBdEdicao.getRegistroBdAtual();
                    r.setValoresOriginaisCamposRegistroBd(false);
                    fCenarioBdEdicao.getGrade().requestFocus();
                }
            }
        }
        if (r != null) {
            r.atualizarPainelBd(true);
        }
        HabilitarBotoes(true, true, true, false, false, true);
        fPertinenciaBd.setLiberarEdicao(false, false);
        setCores();
    }

    /**************************************************************************/
    /***                                                                    ***/
    /**************************************************************************/
    private void acaoRelatorio() {
        if (fCenarioBdEdicao == null) {
            return;
        }
        //
        final CPainelBd p = fCenarioBdEdicao.getPainelBd();
        if (p == null) {
            return;
        }
        Boolean ok = p.getOpcoes();
        //
        if (!ok) return;
        //
        JasperPrint jp = null;
        jp = p.getJasperPrint();
        if (jp != null) {
            JasperViewer.viewReport(jp, false);
            return;
        }
        //
        CRelatorioBasicoCenario rbn = null;
        rbn = p.getRelatorio(true);
        //
/*
        if (rbn == null) {
        rbn = p.getBaseRelatorio();
        fPertinenciaBd.relatorioBasico(rbn);
        }
         */
        //
        if (rbn == null) {
            //rbn = new CRelatorioBasicoCenario(fCenarioBdEdicao, true);
            //  fPertinenciaBd.relatorioBasico(rbn);
        }
        //
        if (rbn != null) {
            try {
                HashMap hm = new HashMap();
                rbn.runReport(
                        rbn, hm, fPertinenciaBd.getGlobal().getConectorBd().getConnection());
            } catch (JRException ex) {
                Logger.getLogger(CDialogoBdCenarioEdicao.class.getName()).log(Level.SEVERE, null, ex);
            }
        }

        /**************************************************************************/
        /***                                                                    ***/
        /**************************************************************************/
    }

    private String getTituloRelatorio() {
        return "";
    }

    /**************************************************************************/
    /***                                                                    ***/
    /**************************************************************************/
    private void swBtnRelatorioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_swBtnRelatorioActionPerformed
        acaoRelatorio();
    }//GEN-LAST:event_swBtnRelatorioActionPerformed

    /**************************************************************************/
    /***                                                                    ***/
    /**************************************************************************/
    private void swBtnGeral1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_swBtnGeral1ActionPerformed
        CPainelBd p = fCenarioBdEdicao.getPainelBd();
        p.acaoBotaoGeral1();
    }//GEN-LAST:event_swBtnGeral1ActionPerformed

    /**************************************************************************/
    /***                                                                    ***/
    /**************************************************************************/
    private void swBtnGeral2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_swBtnGeral2ActionPerformed
        CPainelBd p = fCenarioBdEdicao.getPainelBd();
        p.acaoBotaoGeral2();
    }//GEN-LAST:event_swBtnGeral2ActionPerformed

    /**************************************************************************/
    /***                                                                    ***/
    /**************************************************************************/
    private void swBtnGeral3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_swBtnGeral3ActionPerformed
        CPainelBd p = fCenarioBdEdicao.getPainelBd();
        p.acaoBotaoGeral3();
    }//GEN-LAST:event_swBtnGeral3ActionPerformed

    private void swBtnExcluirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_swBtnExcluirActionPerformed
        acaoExcluir(evt);

    }//GEN-LAST:event_swBtnExcluirActionPerformed

    private void swBtnAtualizarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_swBtnAtualizarActionPerformed
        fCenarioBd.getPersistenciaBd().recarregarConjuntoDadosBd();
        CGrade g = fCenarioBd.getGrade();
        if (g != null) {
            g.atualizar();
            HabilitarBotoes(true, true, true, false, false, true);
        }
    }//GEN-LAST:event_swBtnAtualizarActionPerformed
    /**************************************************************************/
    /***                                                                    ***/
    /**************************************************************************/
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton swBtbAlterar;
    private javax.swing.JButton swBtnAtualizar;
    private javax.swing.JButton swBtnCancelar;
    private javax.swing.JButton swBtnExcluir;
    private javax.swing.JButton swBtnGeral1;
    private javax.swing.JButton swBtnGeral2;
    private javax.swing.JButton swBtnGeral3;
    private javax.swing.JButton swBtnIncluir;
    private javax.swing.JButton swBtnRelatorio;
    private javax.swing.JButton swBtnSalvar;
    private javax.swing.JPanel swPnlCentral;
    private javax.swing.JPanel swPnlFundo;
    private javax.swing.JPanel swPnlTopo;
    // End of variables declaration//GEN-END:variables
}
